import React from 'react';
import { ElEditTableColumns } from '@/components/el/ElEditTable';
import { ElFormProps } from '@/components/el/ElForm';
import { getCurrencyList } from '../service';
import { ElSearchTableColumns } from '@/components/el/ElSearchTable';
import '../style.less';

// 基础信息表单项
const getBasicItemForm = (): ElFormProps => {
  return {
    labelCol: { span: 8 },
    wrapperCol: { span: 16 },
    items: [
      {
        title: '订单/工单编号',
        name: 'docNo',
        span: 6,
        formOption: {
          type: '$input',
          props: {
            disabled: true,
            placeholder: '请输入订单编号或工单编号'
          }
        }
      },
      {
        title: '',
        name: '',
        span: 18,
        hidden: true,
        formOption: {
          type: '$input',
          props: {
            disabled: true
          }
        }
      },
      {
        title: '订单类型',
        name: 'docTypeName',
        span: 6,
        formOption: {
          type: '$input',
          props: {
            disabled: true
          }
        }
      },
      {
        title: '客户编号',
        name: 'custCode',
        span: 6,
        formOption: {
          type: '$input',
          props: {
            disabled: true
          }
        }
      },
      {
        title: '客户名称',
        name: 'custName',
        span: 6,
        formOption: {
          type: '$input',
          props: {
            disabled: true
          }
        }
      },
      {
        title: '销售公司',
        name: 'ouId',
        span: 6,
        formOption: {
          type: '$mg-select-ou',
          props: {
            disabled: true
          }
        }
      },
      {
        title: '业务员',
        name: 'agentName',
        span: 6,
        formOption: {
          type: '$input',
          props: {
            disabled: true
          }
        }
      },
      {
        title: '订单日期',
        name: 'docTime',
        span: 6,
        formOption: {
          type: '$datePicker',
          props: {
            disabled: true
          }
        }
      },
      {
        title: '下单渠道',
        name: 'soSource',
        span: 6,
        formOption: {
          type: '$udc',
          props: {
            disabled: true,
            prefixStr: '/yst-system',
            domain: 'SAL',
            udc: 'SO_SOURCE'
          }
        }
      },
      {
        title: '客户联系人',
        name: 'custContactName',
        span: 6,
        formOption: {
          type: '$input',
          props: {
            disabled: true
          }
        }
      },
      // {
      //   title: '工单编号',
      //   name: 'docNo',
      //   span: 6,
      //   formOption: {
      //     type: '$input',
      //     props: {
      //       disabled: true
      //     }
      //   }
      // },
      {
        title: '支付状态',
        name: 'payStatusName',
        span: 6,
        formOption: {
          type: '$input',
          props: {
            disabled: true
          }
        }
      },
      {
        title: '是否含税',
        name: 'taxInclFlag',
        span: 6,
        formOption: {
          type: '$select',
          props: {
            disabled: true,
            options: [
              { value: '1', label: '是' },
              { value: '0', label: '否' }
            ]
          }
        }
      },
      {
        title: '客户联系人电话',
        name: 'custContactTel',
        span: 6,
        formOption: {
          type: '$input',
          props: {
            disabled: true
          }
        }
      },
      {
        title: '含税总金额',
        name: 'amt',
        span: 6,
        formOption: {
          type: '$input',
          props: {
            disabled: true
          }
        }
      },
      {
        title: '应收款金额',
        name: 'openAmt',
        span: 6,
        formOption: {
          type: '$input',
          props: {
            disabled: true
          }
        }
      },
      {
        title: '已支付金额',
        name: 'payedAmt',
        span: 6,
        formOption: {
          type: '$input',
          props: {
            disabled: true
          }
        }
      },
      {
        title: '待收款金额',
        name: 'apAmt',
        span: 6,
        formOption: {
          type: '$input',
          props: {
            disabled: true
          }
        }
      },
      {
        title: '支付时间',
        name: 'payTime',
        span: 6,
        formOption: {
          type: '$datePicker',
          props: {
            disabled: true,
            showTime: true,
            format: 'YYYY-MM-DD HH:mm:ss'
          }
        }
      },
      {
        title: '币种',
        name: 'currCode',
        span: 6,
        formOption: {
          type: '$select',
          props: {
            request: getCurrencyList,
            placeholder: '请选择',
            disabled: true,
            transfer: {
              label: 'currName',
              value: 'currCode'
            }
          }
        }
      },
      {
        title: '本币币种',
        name: 'homeCurr',
        span: 6,
        formOption: {
          type: '$select',
          props: {
            request: getCurrencyList,
            placeholder: '请选择',
            disabled: true,
            transfer: {
              label: 'currName',
              value: 'currCode'
            }
          }
        }
      },
      {
        title: '汇率',
        name: 'currRate',
        span: 6,
        formOption: {
          type: '$input',
          props: {
            disabled: true
          }
        }
      },
      {
        title: '备注',
        name: 'remark',
        span: 12,
        labelCol: { span: 4 },
        wrapperCol: { span: 20 },
        formOption: {
          type: '$input',
          props: {
            disabled: true
          }
        }
      }
    ]
  };
};

// 订单明细
const getOrderDetailColumns = (): Array<ElEditTableColumns> => {
  const isEdit = false; //控制可编辑表格是否可以编辑
  return [
    {
      title: '行号',
      width: 60,
      align: 'left',
      dataIndex: 'lineNo',
      editable: isEdit,
      fixed: true
    },
    {
      title: '行类型',
      width: 100,
      align: 'center',
      dataIndex: 'lineTypeName',
      editable: isEdit
    },
    {
      title: '行状态',
      width: 100,
      align: 'center',
      dataIndex: 'lineStatusName',
      editable: isEdit
    },
    {
      title: '商品编号',
      width: 200,
      align: 'left',
      dataIndex: 'itemCode',
      editable: isEdit
    },
    {
      title: '商品名称',
      width: 250,
      align: 'left',
      dataIndex: 'itemName',
      editable: isEdit
    },
    {
      title: '数量',
      width: 90,
      align: 'right',
      dataIndex: 'qty',
      editable: isEdit
    },
    {
      title: '单位',
      width: 90,
      dataIndex: 'uomName',
      editable: isEdit
    },
    {
      title: '含税价格',
      width: 90,
      align: 'right',
      dataIndex: 'price',
      editable: isEdit
    },
    {
      title: '应收款金额',
      width: 100,
      align: 'right',
      dataIndex: 'openAmt',
      editable: isEdit
    },
    {
      title: '已收款金额',
      width: 100,
      align: 'right',
      dataIndex: 'payedAmt',
      editable: isEdit
    },
    {
      title: '待收款金额',
      width: 100,
      align: 'right',
      dataIndex: 'apAmt',
      editable: isEdit
    },
    {
      title: '支付状态',
      width: 90,
      align: 'center',
      dataIndex: 'payStatusName',
      editable: isEdit
    },
    {
      title: '含税金额',
      width: 90,
      align: 'right',
      dataIndex: 'amt',
      editable: isEdit
    },
    {
      title: '备注',
      width: 150,
      dataIndex: 'remark',
      editable: isEdit
    }
  ];
};

// 订单收款明细
const getOrderReceiverDetailColumns = (): Array<ElSearchTableColumns> => {
  return [
    {
      title: '行号',
      width: 60,
      align: 'left',
      dataIndex: 'lineNo',
      fixed: true,
      render: (text, record, index) => {
        return index + 1;
      }
    },
    {
      title: '付款方式',
      width: 120,
      align: 'center',
      dataIndex: 'receiptMethodName'
    },
    {
      title: '收款金额',
      width: 100,
      align: 'right',
      dataIndex: 'receiptAmt'
    },
    {
      title: '收款日期',
      width: 110,
      align: 'center',
      dataIndex: 'receiptDate'
    },
    {
      title: '收款流水号',
      width: 150,
      align: 'center',
      dataIndex: 'receiptSerial'
    },
    {
      title: '备注',
      width: 150,
      dataIndex: 'remark'
    }
  ];
};

export {
  getBasicItemForm, // 基础信息表单项
  getOrderDetailColumns, // 订单明细
  getOrderReceiverDetailColumns // 订单收款明细
};
